package com.ruiyian.bridge.opreations.service.impl;

import com.ruiyian.bridge.info.mapper.DipmonitorInfoMapper;
import com.ruiyian.bridge.info.mapper.DistanceInfoMapper;
import com.ruiyian.bridge.info.mapper.Mmh2oInfoMapper;
import com.ruiyian.bridge.opreations.service.MonitorDataExcelService;
import com.ruiyian.bridge.project.enums.DeviceTypeEnum;
import com.ruiyian.bridge.project.domain.vo.DataAnalysisVo;
import com.ruiyian.bridge.project.domain.vo.MonitorDataExcelBo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chong
 * @email 673426164@qq.com
 * @create 2022/5/5
 * Desc: 数据导出
 */
@Service
public class MonitorDataExcelServiceImpl implements MonitorDataExcelService {

    @Autowired
    private DistanceInfoMapper distanceMapper;
    @Autowired
    private Mmh2oInfoMapper mmh2oInfoMapper;
    @Autowired
    private DipmonitorInfoMapper dipmonitorInfoMapper;
    /**
     * 列表查询
     * @param query
     * @return
     */
    @Override
    public List<DataAnalysisVo> queryMonitorDataPageList(MonitorDataExcelBo query) {
        List<DataAnalysisVo> result = null;
        if (!StringUtils.isEmpty(query.getStartTime())){
            query.setStartTime(query.getStartTime() + " 00:00:00");
        }
        if (!StringUtils.isEmpty(query.getEndTime())){
            query.setEndTime(query.getEndTime() + " 23:59:59");
        }
        if (query.getMonitorType().intValue() == DeviceTypeEnum.DISTANCE.getType()){
            result = distanceMapper.queryMonitorDataPageList(query);
        }else if(query.getMonitorType().intValue() == DeviceTypeEnum.MMH2O.getType()){
            result = mmh2oInfoMapper.queryMonitorDataPageList(query);
        }else if(query.getMonitorType().intValue() == DeviceTypeEnum.DIPMONITOR.getType()){
            result = dipmonitorInfoMapper.queryMonitorDataPageList(query);
        }
        return result;
    }
}
